package ufs.cmds;

public class UFSCommandsConstants {

	private UFSCommandsConstants(){}
	
	public static final String nameFile = "ufsFileDisk";
	
	public static final int BOOT_SECTOR_SIZE = 32;
	
	public static final short DEFAULT_DIM_CLUSTER = 1024;
	public static final int DEFAULT_NUM_CLUSTER = 1024;
	public static final String DEFAULT_NAME_VOL = "ufsDisk";

	public static final int DEFAULT_NAME_VOL_SIZE = 10;
	
	public static final int FAT_ITEM_SIZE = 4;
		
	public static final byte MINOR_VERSION = 1;
	public static final byte MAJOR_VERSION = 0;
	
	public static final int FIRST_CLUSTER_INDEX = 1;
	
	public static final int FIRST_CODE_TYPE = 187;
	public static final byte SECOND_CODE_TYPE = 68;
	
	public static final int UNMOUNTED_PARTITION = 0;
	public static final int MOUNTED_PARTITION = 15;	

	/* ERROR MESSAGES*/
	public static final String WRONG_C_ARG = "A value among %sis expected for -%s";
	public static final String WRONG_K_ARG = "An integer value is expected for -%s";
	public static final String WRONG_N_ARG = "A String is expected for -%s option (max length: "+DEFAULT_NAME_VOL_SIZE+")" ;
	public static final String FILE_NOT_CREATED = "Filesystem couldn't be created";
	public static final String FS_ALREADY_EXISTS = "The filesystem already exists";
	public static final String FS_DOES_NOT_EXISTS = "The filesystem does not exist";
	
	//ufs_mount/ufs_unmount messages
	public static final String PARTITON_ALREADY_MOUNTED = "The partition was already mounted";
	public static final String MOUNT_OK = "The partition is mounted correctly";
	public static final String FAT_CORRUPTED = "The File Allocation Table is corrupted";


	

	
	
	public static enum ClusterDims {
		DIM1(512),
		DIM2(1024),
		DIM3(2048),
		DIM4(4096),
		DIM5(8192);
		
		private int dim;
		
		private ClusterDims(int d) {
			dim = d;
		}/*
		public int getDim() {
			return dim;
		}*/
		public static boolean contains(int d) {
			ClusterDims[] cds = ClusterDims.values();
			for(ClusterDims cd : cds) {
				if(d == cd.dim) {
					return true;
				}
			}
			return false;
		}

		public static String printSet() {
			StringBuilder ret = new StringBuilder();
			ClusterDims[] cds = ClusterDims.values();
			for(ClusterDims cd : cds) {
				ret.append(cd.dim + ", ");
			}
			return ret.toString();
		}
		
	}
}
